home *** CD-ROM | disk | FTP | other *** search
- /*
-
- Autodesk Device Interface/ADI Driver for Microsoft Mouse
-
- Now it's time to try this thing,
- and hope it works for me.
- Microsoft, Microsoft,
- M-O-U-S-E!
-
- Original driver designed and implemented in January 1984.
- Converted to ADI format September 1986
- */
-
- #include "stdio.h"
- #include "dos.h"
- #include "adi.h"
- #include "dgadi.h"
- #define VERSION "1.00"
- #define REVDATE "10/28/86"
-
- /* Default interrupt vector for digitizer drivers is 0x79. This is
- selectable by user during AutoCAD configuration. AutoSketch uses
- 0x79 only. */
-
- #define VECTOR 0x79 /* Interrupt vector used for messages */
- #define iabs(x) ((x)<0 ? -(x) : (x)) /* integer absolute value */
-
- static struct comreg acad;
-
- /* Registers defined as mouse input and output values per Microsoft Mouse
- Installation and Operation Manual 8808-100-00 P/N 99F37B Chapter 4 */
-
- struct XREG r;
-
- #define m1 r.ax
- #define m2 r.bx
- #define m3 r.cx
- #define m4 r.dx
-
- /* Default slow/fast/threshold values */
- static int mi_slow = 25, mi_fast = 50, mi_thresh = 9;
-
- struct {int mdadr, mdseg;} mdp;
-
- static int prior = 0, enabled = 0, c;
- static int x = 0, y = 0;
- #define dgx acad.arg1
- #define dgy acad.arg2
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- printf("\n--- Autodesk Device Interface/ADI Driver ---\n");
- printf("Microsoft Mouse driver Vers. %s installed as INT %03xh.",VERSION,VECTOR);
- printf("\nSample ADI Driver created %s by Autodesk, Inc.\n",REVDATE);
-
- /* ADI driver developer should include name of company, or company and
- individual, responsible for creation of ADI device driver and date
- of driver creation to aid in identifying driver. */
-
- while (1)
- {
- iwait(VECTOR, &acad, &acad);
- #ifdef DEBUG
- printf("\n ** Digitizer(%d): %d(%04x), %d(%04x), %d(%04x) **",
- acad.code, acad.arg1, acad.arg1, acad.arg2, acad.arg2, acad.arg3, acad.arg3);
- #endif
- switch (acad.code)
- {
- case INIT:
- if (acad.arg1 != INTLEVEL) /* Acceptable interface? */
- {
- acad.code = 0; /* Nope...return error */
- break; /* and get out right now */
- }
-
- /* Now before we call the supposedly-installed mouse
- driver, let's look before we leap and see if the interrupt
- vector is really there. The following code reads the
- interrupt vector from page zero and makes sure it's at
- least nonzero before we try the mouse. */
-
- peek(0, 51<<2, &mdp, sizeof mdp);
-
- if (mdp.mdadr == 0 || mdp.mdseg==0)
- m1=0;
- else
- mouse(0); /* Initialise the mouse */
- if (m1 == 0)
- printf(/*MSG5*/"\nMouse is not installed.");
- else
- enabled=1;
- acad.code = enabled;
- acad.arg1 = 0; /* We're a mouse-kill tablet stuff */
- acad.arg2 = 0; /* Everything we say is significant */
- break;
-
- case TERM:
- break;
-
- case SENSE:
-
- /* Digitizer input call: returns status values of:
-
- 0: No valid point digitized
- 2: (bx, cx) is a tracking coordinate pair
- 3: (bx, cx) is a point select coordinate pair
- 4: (bx) is a button number
- 5: (bx) is a button number; (cx, dx) is a coordinate
- pair giving the location at which the button was
- pressed
- */
-
- if (!enabled)
- {
- acad.code = 0; /* Dead mouse. Return no sample */
- break;
- }
-
- /* If we returned a menu selection last time, now return the
- reading that came with it: */
-
- if (prior == 4)
- {
- dgx = x; dgy = y;
- acad.code = (prior = 5);
- break;
- }
-
- mouse(3);
- c=m2 & 0x03;
- mouse(11);
-
- /* Wait for button release after select. */
-
- if (prior > 2 && c != 0)
- {
- acad.code = 0;
- break;
- }
-
- /* Convert sample to absolute */
-
- cupd(m3, &x);
- cupd(-m4, &y); /* Down is positive. Neat, huh? */
-
- /* All button bits clear indicates tracking coordinate,
- Bit 0 = left button = point select
- 1 = right button = menu item 0 */
-
- if (c & 0x02)
- {
- prior = 4; /* Menu item. */
- dgx = 0;
- }
- else
- {
- dgx = x; dgy = y; /* Point. */
- prior = c ? 3 : 2;
- }
- acad.code = prior;
- break;
- } /* end SWITCH */
- } /* end WHILE */
- }
-
-
- /* Convert relative coordinate to absolute */
-
- static cupd(chg, pc)
- int chg;
- int *pc;
- {
- *pc += chg * ((iabs(chg) > mi_thresh) ?
- mi_fast : mi_slow);
- if (*pc < 0)
- *pc = 0;
- if (*pc > 20480)
- *pc = 20480;
- }
-
- /* MOUSE -- Send a function to the mouse */
-
- static mouse(fcn)
- int fcn;
- {
- m1=fcn;
- int86(51,&r,&r);
- }
-